package com.java.string;

import java.util.StringJoiner;

public class StringJoinerAPI {
    public static void main(String[] args) {
        StringJoiner stringJoiner = new StringJoiner(", ", "[", "]");
        
        // toString：将StringJoiner转为String
        System.out.println(stringJoiner); // []
        System.out.println(stringJoiner.toString()); // []
        
        // add：添加数据到StringJoiner尾部
        stringJoiner.add("0");
        stringJoiner.add("1");
        stringJoiner.add("2");
        System.out.println(stringJoiner); // [0, 1, 2]
        
        // length：获取StringJoiner内的数据长度
        System.out.println(stringJoiner.length()); // 9
    }
}
